/**
 * A class used to represent a point in a 3-dimensional space
 * @author Lorenzo Porzi
 *
 */
public class Point3D {
	public double x, y, z; // Coordinates
	
	public Point3D(double x, double y, double z) {
		this.x = x;
		this.y = y;
		this.z = z;
	}
	
	public Point3D(double x, double y) {
		this.x = x;
		this.y = y;
		this.z = 0;
	}
	
	public Point3D(Point3D p) {
		this.x = p.x;
		this.y = p.y;
		this.z = p.z;
	}
	
	@Override
	public String toString() {
		return "[" + x + " , " + y + " , " + z + "]";
	}
	
	public Point3D sum(Point3D p) {
		return new Point3D(x + p.x, y + p.y, z + p.z);
	}
	
	public double squareDistance(Point3D p) {
		return (p.x - x) * (p.x - x) + (p.y - y) * (p.y - y) + (p.z - z) * (p.z - z);
	}
}
